import 'dart:async';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_full_pdf_viewer/full_pdf_viewer_scaffold.dart';
import 'package:path_provider/path_provider.dart';

// 阅读pdf 文件
class ReadLocalFilePdfDoc extends StatefulWidget {
  final String name;
  ReadLocalFilePdfDoc({@required this.name,Key key }):super(key:key );
  @override
  _ReadLocalFilePdfDocState createState() => _ReadLocalFilePdfDocState();
}

class _ReadLocalFilePdfDocState extends State<ReadLocalFilePdfDoc> {
  Future<String> getFilePath()async{
    String dir = (await getApplicationDocumentsDirectory()).path;
    return dir ;
  }
  String path ="";
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getFilePath().then((filePath){
      setState(() {
        path = filePath+"/${widget.name}";
        print("path = $path");
      });
    });
  }
  @override
  Widget build(BuildContext context) {
    return PDFViewerScaffold(
        appBar: AppBar(
          title: Text(widget.name),

        ),
        path: path);
  }
}
